package org.gruposp2p.dnie.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.gruposp2p.dnie.model.xmladapter.DNIeDocumentToSignAdapter;

/**
 *
 * @author jj
 */
@XmlType
@XmlRootElement(name = "DnieDocumentToSignOption")
@XmlAccessorType(XmlAccessType.NONE)
@Entity
@Table(name = "DNIEDOCUMENTTOSIGNOPTION", catalog = "DNIE")
@NamedQueries({
	@NamedQuery(name = "DNIeDocumentToSignOption.findAll", query = "SELECT d FROM DNIeDocumentToSignOption d"), 
	@NamedQuery(name = "DNIeDocumentToSignOption.findById", query = "SELECT d FROM DNIeDocumentToSignOption d WHERE d.id = :id"), 
	@NamedQuery(name = "DNIeDocumentToSignOption.findByContent", query = "SELECT d FROM DNIeDocumentToSignOption d WHERE d.content = :content")})
public class DNIeDocumentToSignOption implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    @XmlElement
    private Integer id;
    @Basic(optional = false)
    @Column(name = "CONTENT", nullable = false, length = 500)
    @XmlElement
    private String content;
    @JoinColumn(name = "DNIEDOCUMENTTOSIGN_ID", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    @XmlElement
    @XmlJavaTypeAdapter(DNIeDocumentToSignAdapter.class)
    private DNIeDocumentToSign dnieDocumentToSignId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "dnieDocumentToSignOptionId")
    private Collection<DNIeSignedDocumentOptionSelected> dnieSignedDocumentOptionSelectedCollection;

    public DNIeDocumentToSignOption() {
    }

    public DNIeDocumentToSignOption(Integer id) {
        this.id = id;
    }

    public DNIeDocumentToSignOption(Integer id, String content) {
        this.id = id;
        this.content = content;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public DNIeDocumentToSign getDNIeDocumentToSignId() {
        return dnieDocumentToSignId;
    }

    public void setDNIeDocumentToSignId(DNIeDocumentToSign dnieDocumentToSignId) {
        this.dnieDocumentToSignId = dnieDocumentToSignId;
    }

    public Collection<DNIeSignedDocumentOptionSelected>
            getDnieSignedDocumentOptionSelectedCollection() {
        return dnieSignedDocumentOptionSelectedCollection;
    }

    public void setDnieSignedDocumentOptionSelectedCollection(
            Collection<DNIeSignedDocumentOptionSelected> dnieSignedDocumentOptionSelectedCollection) {
        this.dnieSignedDocumentOptionSelectedCollection = dnieSignedDocumentOptionSelectedCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DNIeDocumentToSignOption)) {
            return false;
        }
        DNIeDocumentToSignOption other = (DNIeDocumentToSignOption) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dniedatabasemodel01.DNIeDocumentToSignOption[id=" + id + "]";
    }

}
